// pages/index/wholeRent/wholeRent.js
Page({

    /**
     * 页面的初始数据
     */

    data: {
      moreHouseSourse:[],
     
        options: [{
                "label": "区域",
                "value": '区域',
                "children": [{
                        "label": "北京",
                        "value": "39.9042,116.4074"
                    },
                    {
                        "label": "上海",
                        "value": "31.2304,121.4737"
                    },
                    {
                        "label": "广州",
                        "value": "23.1291,113.2644"
                    },
                    {
                        "label": "深圳",
                        "value": "22.5429,114.0596"
                    }
                ]
            },
            {
                "label": "地铁",
                "value": "地铁",
                "children": [{
                        "label": "北京地铁1号线",
                        "value": "39.9042,116.4074"
                    },
                    {
                        "label": "上海地铁2号线",
                        "value": "31.2304,121.4737"
                    },
                    {
                        "label": "广州地铁3号线",
                        "value": "23.1291,113.2644"
                    },
                    {
                        "label": "深圳地铁5号线",
                        "value": "22.5429,114.0596"
                    }
                ]
            },
            {
                "label": "附近",
                "value": '附近',
                "children": [{
                        "label": "距离10km",
                        "value": "10km"
                    },
                    {
                        "label": "距离20km",
                        "value": "20km"
                    },
                    {
                        "label": "距离30km",
                        "value": "30km"
                    }
                ]
            }
        ],
        value: ["", ""],
        rentValue: 'all',
        rent: {
            options: [{
                    value: '0',
                    label: '不限'
                },
                {
                    value: '1',
                    label: '1000-2000'
                },
                {
                    value: '2',
                    label: '2000-3000'
                },
                {
                    value: '3',
                    label: '3000-4000'
                },
                {
                    value: '4',
                    label: '4000-5000'
                },
                {
                    value: '5',
                    label: '5000-6000'
                },
            ],
        },
        sortValue: '0',
        sort: {
            options: [{
                    value: '0',
                    label: '默认排序',
                },
                {
                    value: '1',
                    label: '价格最低',
                },
                {
                    value: '2',
                    label: '时间最新',
                },
                {
                    value: '3',
                    label: '距离最近',
                }
            ],
        },
        direction: [{
                value: 'd0',
                label: '东',
            },
            {
                value: 'd1',
                label: '西',
            },
            {
                value: 'd2',
                label: '南',
            },
            {
                value: 'd3',
                label: '北',
            },
        ],
        area: [{
                value: 'a0',
                label: '10以下',
            },
            {
                value: 'a1',
                label: '10-20',
            },
            {
                value: 'a2',
                label: '20-40',
            },
            {
                value: 'a3',
                label: '40以下',
            },
        ],
        room: [{
                value: 'r0',
                label: '一居',
            },
            {
                value: 'r1',
                label: '二居',
            },
            {
                value: 'r2',
                label: '三居',
            },
            {
                value: 'r3',
                label: '四居以上',
            },
        ],
        directionValue: "",
        areaValue: "",
        roomValue: "",
    },
    onIconTap() {
        wx.navigateBack()
    },
    onChange(e) {
        console.log(e)
        this.setData({
            value: e.detail.value,
        });
    },
    rentOnChange(e) {
        this.setData({
            rentValue: e.detail.value
        })
    },
    sortOnChange(e) {
        this.setData({
            sortValue: e.detail.value
        })
    },
    directionClick(e) {
        this.setData({
            directionValue: e.currentTarget.dataset.item.value,
        })
    },
    areaClick(e) {
        this.setData({
            areaValue: e.currentTarget.dataset.item.value,
        })
    },
    roomClick(e) {
        this.setData({
            roomValue: e.currentTarget.dataset.item.value,
        })
    },
    reSet() {
        this.setData({
            directionValue: "",
            areaValue: "",
            roomValue: "",
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
  //更多房源
  getMoreHouseSourse(){
    wx.request({
      url: 'http://localhost:8080/ihome/home/list',
      header: {
        'Authorization': 'Bearer ' + wx.getStorageSync('token')
      },
      data:{
        lessor:1,
        lease_type:1,
        // pageNum: 1,
        // pageSize: 3
      },
      success:(resp=>{
        console.log(resp.data)
        this.setData({
          moreHouseSourse:resp.data.rows
        })
      })
    })
  },


  onLoad(options) {
   
    this.getMoreHouseSourse();
  },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})